/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.alien.admin.modules.publisher.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author zhouseyi
* @date 2021-11-03
**/
@Entity
@Data
@Table(name="dp_publish_project")
public class PublishProject implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "flow_id")
    @ApiModelProperty(value = "流程id")
    private Long flowId;

    @Column(name = "project_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "项目id")
    private Long projectId;

    @Column(name = "branch",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "发布分支")
    private String branch;

    @Column(name = "version",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "发布版本号")
    private String version;

    @Column(name = "gray",nullable = false)
    @NotNull
    @ApiModelProperty(value = "上线方式")
    private Integer gray;

    @Column(name = "replicas",nullable = false)
    @NotNull
    @ApiModelProperty(value = "实例数量")
    private Integer replicas;

    @Column(name = "gray_replicas")
    @ApiModelProperty(value = "灰度数量")
    private Integer grayReplicas;

    @Column(name = "resource_id")
    @ApiModelProperty(value = "资源规格")
    private Integer resourceId;

    public void copy(PublishProject source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}